package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.util.Log;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.util.ArrayList;
import java.util.List;

@Deprecated
public final class zd {
    private final Context ˊ;

    public zd(Context context) {
        this.ˊ = context;
    }

    public List<yu> ˊ() {
        if (Log.isLoggable("ManifestParser", 3)) {
            Log.d("ManifestParser", "Loading Glide modules");
        }
        List<yu> arrayList = new ArrayList();
        try {
            ApplicationInfo applicationInfo = this.ˊ.getPackageManager().getApplicationInfo(this.ˊ.getPackageName(), DnsConfig.MAX_CACHE_ENTRIES);
            if (applicationInfo.metaData == null) {
                if (Log.isLoggable("ManifestParser", 3)) {
                    Log.d("ManifestParser", "Got null app info metadata");
                }
                return arrayList;
            }
            if (Log.isLoggable("ManifestParser", 2)) {
                Log.v("ManifestParser", "Got app info metadata: " + applicationInfo.metaData);
            }
            for (String str : applicationInfo.metaData.keySet()) {
                if ("GlideModule".equals(applicationInfo.metaData.get(str))) {
                    arrayList.add(ˎ(str));
                    if (Log.isLoggable("ManifestParser", 3)) {
                        Log.d("ManifestParser", "Loaded Glide module: " + str);
                    }
                }
            }
            if (Log.isLoggable("ManifestParser", 3)) {
                Log.d("ManifestParser", "Finished loading Glide modules");
            }
            return arrayList;
        } catch (Throwable e) {
            throw new RuntimeException("Unable to find metadata to parse GlideModules", e);
        }
    }

    private static yu ˎ(String str) {
        try {
            Class cls = Class.forName(str);
            Object obj = null;
            try {
                obj = cls.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
            } catch (Exception e) {
                ˏ(cls, e);
            } catch (Exception e2) {
                ˏ(cls, e2);
            } catch (Exception e22) {
                ˏ(cls, e22);
            } catch (Exception e222) {
                ˏ(cls, e222);
            }
            if (obj instanceof yu) {
                return (yu) obj;
            }
            throw new RuntimeException("Expected instanceof GlideModule, but found: " + obj);
        } catch (Throwable e3) {
            throw new IllegalArgumentException("Unable to find GlideModule implementation", e3);
        }
    }

    private static void ˏ(Class<?> cls, Exception exception) {
        throw new RuntimeException("Unable to instantiate GlideModule implementation for " + cls, exception);
    }
}
